//1. 引入Vue
import Vue from "vue";

//2. 引入VueRouter
import VueRouter from "vue-router";

//引入路由组件
import Login from "../pages/Login";
import Home from "../pages/Home";
import Music from "../pages/Home/Music";
import News from "../pages/Home/News";

//3. 让Vue使用VueRouter这个插件
Vue.use(VueRouter);

//4.创建路由器对象
export default new VueRouter({
  //在实例化路由器对象的配置中,书写路由表配置
  routes: [
    { path: "/login", component: Login },
    {
      path: "/home",
      component: Home,
      children: [
        //params传参
        // { path: "music/:id/:time?", component: Music ,name:'music'},
        {
          path: "music",
          component: Music,
          name: 'music',
           //props传参
          props: (route) => {
            return { ...route.query }
          }
        },
        {
          path: "news",
          component: News,
          name: "news",
        },
        //二级路由重定向 默认
        { path: "", component: News },
        //二级路由重定向 指定
        // { path: "", redirect:"/home/news" },
      ]
    },
    //重定向
    { path: "/", redirect: "/login" },
  ],
});
